<template>
	<view :class="{colo:iscolo}" v-show="listshow" >
	<view class="frieds" @tap="entry" @longpress="long" >
		<image :src="pic" mode="scaleToFill"></image>
		<view style="display: flex;justify-content: space-between;width: 84%;">
			<text>
				<text class="users">{{user.name}}\n</text>
				<text class="crx">{{user.duancrx}}</text>
			</text>
			<view class="time">
			<text>{{time}}</text>
			<text v-show="user.bt||buttoncol" class="crxtext icon iconfont icon-yuandianxiao"></text>
			</view>
		</view>
	</view>
	</view>
</template>

<script>
	export default {
		props: {
			user: Object,
		},
		data() {
			return {
				time: Number,
				pic: String,
				longpess: false,
				iscolo:false,
				listshow:true,
				// 默认
				buttoncol:false
			};
		},
		methods: {
			// 删除联系人
			del()
			{
				this.listshow=false
			},
			// 取消置顶
			meclick() {
			       this.iscolo=false
			      },
				  // 置顶
				  udclick()
				  {
					  this.iscolo=true
					  },
					  
			// 长按置顶
			long() {
				console.warn("长按")
				this.iscolo=true
				this.$emit('longpress')
			},
			
			entry() {
				// 触发时间
				this.changetime()
				uni.navigateTo({
					url: "../../pageA/liaotiao/liaotiao?name=" + this.user.name + "&con=" + this.user.crx + "&pic=" + this.pic,

				})
				try
				{
					this.user.bt=false
				}catch
				{
					console.log("错误")
				}
				
			},
			// 时间函数
			changetime() {
				let date = new Date()
				let hours, mintes
				// console.log(date.getHours(),this.user.crx,date.getMinutes())
				if (date.getMinutes() < 10) {
					mintes = '0' + date.getMinutes()
				} else {
					mintes = date.getMinutes()
				}
				if (date.getHours() < 10) {
					hours = '0' + date.getHours()
				} else {
					hours = date.getHours()
				}
				this.time = `${hours}:${mintes}`
			}
		},
		created() {
			this.pic = this.user.src
			// console.log(this.user.src,this.pic)s
			this.changetime()
			// 长度判断
			if (this.user.crx.length > 15) {
				this.user.duancrx = this.user.crx.substring(0, 14) + '...'
			} else {
				this.user.duancrx = this.user.crx
			}
		},

	}
</script>

<style lang="less" scoped>
	// 是否深色
	.colo{
		background-color: #e6e6e6;
	}
	
	.frieds {
		width: 96%;
		// margin: 2%;
		margin: 0 auto;
		height: 135rpx;
		line-height: 150rpx;
		// background-color: red;
		border-bottom: 1px solid #D9D9D9;
		// padding-bottom: 8px;
		display: flex;
		align-items: center;
		justify-content: space-between;

		image {
			width: 100rpx;
			height: 100rpx;
			border-radius: 20rpx;
		}

		view {
			.users {
				font-size: 34rpx;
				font-weight: bolder;
			}

			.time {
				font-size: 24rpx;
				color: #b0b0b0;
				display: flex;
				flex-direction: column;
				align-items: center;
				.crxtext
				{
					font-size: 50rpx;
					color: #e80003;
				}
			}

			.crx {
				font-size: 25rpx;
				color: #b0b0b0;
			}
		}

	}
</style>
